<template>
  <div class="viewcontainer" v-if="dataset">
    <el-row class="view-header">
      <el-col :span="22">
        <hi-lquery
          :columnsTotal="4"
          v-bind="queryPanel"
          :target="dataset"
        ></hi-lquery>
      </el-col>
    </el-row>
    <el-row class="view-main">
      <el-table
        ref="dataTable"
        :row-class-name="tableRowClassName"
        :data="dataset.data"
        height="100%"
        style="width: 100%"
        v-loading="dataset.loading"
      >
        <el-table-column type="index" width="50" />
        <el-table-column prop="FSHOPDESC" label="店铺" width="160" />
        <el-table-column prop="FGOODSNUMBER" label="店内编码" width="160" />
        <el-table-column prop="FBARCODE" label="条形码" width="160" />
        <el-table-column prop="FDESC" label="通用名称" width="160" />
        <!-- <el-table-column prop="FBRAND" label="品牌" width="160" /> -->
        <el-table-column prop="FUNIT" label="单位" width="160" />
        <el-table-column prop="FSPEC" label="规格" width="300">
          <template slot-scope="scope">
            <div class="text-truncate" :title="scope.row.FSPEC">
              {{ scope.row.FSPEC }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="FAMOUNT"
          label="数量"
          align="right"
          width="100"
        />
        <el-table-column
          prop="FSTOREAMOUNT"
          label="剩余数量"
          align="right"
          width="100"
        />
        <el-table-column prop="FPRICE" label="单价" align="right" width="100">
          <template slot-scope="scope">
            {{ formatMoney(scope.row.FPRICE) }}
          </template>
        </el-table-column>
        <el-table-column prop="FMONEY" label="金额" align="right" width="100">
          <template slot-scope="scope">
            {{ formatMoney(scope.row.FMONEY) }}
          </template>
        </el-table-column>
        <el-table-column prop="FORDERNAME" label="来源单据" width="120" />

        <el-table-column prop="FINOROUT" label="出库或入库" width="160" />
        <el-table-column prop="FCREATEDATE" label="时间" width="160" />
      </el-table>
    </el-row>
    <el-row class="view-footer pagebar">
      <hi-pagination
        background
        :total="dataset.total"
        :target="dataset"
      ></hi-pagination>
    </el-row>
  </div>
</template>

<script>
import {
  HiPagination,
  HiLquery,
  HiVquery,
  DataSetContainer,
  HiForm,
  utils,
} from "hi-ui";
import viewBase from "@/views/base";
import storeOutinCfg from "./dataset";
export default {
  name: "outinlist",
  extends: viewBase,
  components: { HiPagination, HiLquery, HiVquery, HiForm },
  data() {
    let datasetCfg = Object.assign({}, storeOutinCfg, {
      action: "autoAction",
    });
    return {
      //数据桥梁
      dataBridge: new Map(),
      // 数据集
      dataset: null,
      //数据集配置
      datasetCfg: datasetCfg,
      total: 100,
      //查询面板配置
      queryPanel: {
        fields: [
            {
            label: "店铺",
            name: "FSHOPDESCID",
            element: "hi-select-grid",
            props: {
              selectOption: {
                loading: true,
                multiple: false,
                clearable: true,
                filterable: true,
                "allow-create": true,
                "collapse-tags": true,
              },
              lookup: {
                modelFile: "database/shop/dataset/ShopEntity.xml",
                label: "FDESC",
                filtername: "FDESC",
                tableprops: {
                  // border:true,
                  hideRowBorder: true,
                  stripe: true,
                  "show-header": false,
                  //fit:false,
                  size: "mini",
                  "max-height": 400,
                  white_space_nowrap: true,
                },
                returnFields: {
                  FSHOPDESCID: "FNUMBER",
                },
                columns: [
                  {
                    name: "FDESC",
                    label: "通用名称",
                  },
                ],
              },
            },
          },
          {
            element: "el-input",
            label: "店内编码",
            name: "FGOODSNUMBER",
          },
          {
            // element: "el-input",
            label: "通用名称",
            name: "FDESC",
            element: "hi-select-grid",
            props: {
              selectOption: {
                loading: true,
                multiple: false,
                clearable: true,
                filterable: true,
                "allow-create": true,
                "collapse-tags": true,
              },
              lookup: {
                modelFile: "database/drug/dataset/DrugEntity.xml",
                // label: "FDESC",
                // filtername: "FCOMMON",
                filternames: [
                  {
                    name: "FDESC",
                  },
                  {
                    name: "FPINYIN",
                    // operate: "like",
                  },
                  {
                    name: "FJIANPIN",
                  },
                ],
                active: false,
                tableprops: {
                  // border:true,
                  hideRowBorder: true,
                  stripe: true,
                  "show-header": false,
                  //fit:false,
                  size: "mini",
                  "max-height": 400,
                  white_space_nowrap: true,
                },
                returnFields: {
                  FDESC: "FDESC",
                  // FSHOPDESCID: "FNUMBER",
                },
                columns: [
                  {
                    name: "FDESC",
                    label: "通用名称",
                  },
                ],
              },
            },
          },

        ],
      },
    };
  },
  model: {
    prop: "value",
    event: "valuechange",
  },
  props: {
    value: {
      type: Object,
    },
  },

  computed: {},
  watch: {},
  methods: {
    tableRowClassName({ row, rowIndex }) {
      if (row.FAMOUNT > 0) {
        return "warning-row";
      } else {
        return "success-row";
      }
    },
    formatMoney(val) {
      return utils.number.format(val, "￥");
    },
    /*  afterquery() {
      this.dataset.load();
    }, */
  },
  mounted() {
    this.dataset = this.createDataSet(this.datasetCfg);
    this.dataBridge.set(this.dataset, ["dataTable", "detailForm"]);
  },
};
</script>
<style rel="stylesheet/scss" lang="scss" scope>
.el-table .warning-row {
  color: green;
}

.el-table .success-row {
  color: red;
}
</style>
